// SPDX-License-Identifier: GPL-2.0
/* smc_interface.c - the interface of SMC module
 *
 * Copyright (C) 2016-2018, LomboTech Co.Ltd.
 * Author: lomboswer <lomboswer@lombotech.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */


#include "smc.h"
#include "n9v1/smc_csp.h"
#include <mach/debug.h>

extern void __iomem *lombo_smc_base;

int smc_read_specail_operation(void)
{
	int err;
	void __iomem *base = get_smc_base_addr();

	err = csp_smc_get_special_mode(base);

	if (err == 0)
		PRT_INFO("special mode is normal mode\n");
	else if (err == 1)
		PRT_INFO("special mode is activation and cold reset mode\n");
	else if (err == 2)
		PRT_INFO("special mode is warm reset mode\n");
	else
		PRT_INFO("special mode is deactivation mode\n");

	return err;
}

int smc_set_specail_operation(mode)
{
	void __iomem *base = get_smc_base_addr();

	csp_smc_sel_special_mode(base, mode);
	return 0;
}

int smc_read_transfer_mode(void)
{
	int err;
	void __iomem *base = get_smc_base_addr();

	err = csp_smc_get_t0_t1_mode(base);
	if (err == 0)
		PRT_INFO("transfer mode is T0, character mode\n");
	else
		PRT_INFO("transfer mode is T1, block mode\n");

	return err;
}

int smc_set_transfer_mode(mode)
{
	void __iomem *base = get_smc_base_addr();

	csp_smc_sel_t0_t1_mode(base, mode);

	return 0;
}

int smc_read_stop_clk_enable(void)
{
	int err;
	void __iomem *base = get_smc_base_addr();

	err = csp_smc_get_stop_clk_en(base);

	return err;
}

int smc_set_stop_clk_enable(enbale)
{
	void __iomem *base = get_smc_base_addr();

	csp_smc_sel_stop_clk_en(base, enbale);

	return 0;
}

int smc_read_block_edc_type(void)
{
	int err;
	void __iomem *base = get_smc_base_addr();

	err = csp_smc_get_block_edc_type(base);
	if (err == 0)
		PRT_INFO("block edc type is LRC\n");
	else
		PRT_INFO("block edc type is CRC\n");

	return err;
}

int smc_set_block_edc_type(mode)
{
	void __iomem *base = get_smc_base_addr();

	csp_smc_sel_block_edc_type(base, mode);

	return 0;
}

int smc_read_start_status(void)
{
	int err;
	void __iomem *base = get_smc_base_addr();

	err = csp_smc_get_start_status(base);
	if (err == 0)
		PRT_INFO("start status is idle\n");
	else
		PRT_INFO("start status is running\n");

	return err;
}
